<?php
include("header.php");

$restoid=null;
if(isset($_GET["restoid"])){
	$restoid=$_GET["restoid"];
}else{
	redirect("index.php");
}
$db = Database::obtain(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();
$sql = "SELECT * FROM `user_info`
WHERE email = '".$_user."'";
$record = $db->query_first($sql);

$record["email"] = $_user;

$sql1="SELECT * FROM info_resto i left join nation_name n on i.RESTO_NATION=n.NATION_ID left join type_resto t on i.RESTO_TYPE_ID=t.TYPE_ID 
WHERE i.RESTO_ID=".$restoid;
$restoinfo = $db->query_first($sql1);
$db->close();

$country=$restoinfo["NATION_NAME_".strtoupper($_lang)];
$restype=$restoinfo["TYPE_NAME_".strtoupper($_lang)];
$resname=$restoinfo["RESTO_NAME_".strtoupper($_lang)];
?>
<script src="js/jquery-1.9.1.js"></script>
<script src="js/ui/jquery.ui.core.js"></script>
<script src="js/ui/jquery.ui.widget.js"></script>
<script src="js/ui/jquery.ui.datepicker.js"></script>
<script src="js/jquery.ui.datepicker-ar.js"></script>
<script src="js/jquery.ui.datepicker-fr.js"></script>
<script type="text/javascript">
function suborder() 
{ 
	var ok = true;

	if(!test_null(document.getElementById("date").value)) 
	{ 
		document.getElementById("ldate").style.color="Red";
		ok = false;  
	}else{
		document.getElementById("ldate").style.color="Black";
	}

	hour = document.getElementById("hour").value;
	if(IsNum(hour)&&hour>=0&&hour<24) 
	{ 
		document.getElementById("lhour").style.color="Black";
	}else{
		document.getElementById("lhour").style.color="Red";
		ok = false;
	}
	minute = document.getElementById("minute").value;
	if(IsNum(minute)&&minute>=0&&minute<60) 
	{ 
		document.getElementById("lminute").style.color="Black";
	}else{
		document.getElementById("lminute").style.color="Red";
		ok = false; 
	}
	if(!IsNum(document.getElementById("peoplenum").value)) 
	{ 
		document.getElementById("lpeoplenum").style.color="Red";
		ok = false;  
	}else{
		document.getElementById("lpeoplenum").style.color="Black";
	}

	
	if(!test_email(document.getElementById("uemail").value)) 
	{ 
		document.getElementById("ulemail").style.color="Red";
		ok = false; 
	}else{
		document.getElementById("ulemail").style.color="Black";
	}
	if(!test_null(document.getElementById("unom").value)) 
	{ 
		document.getElementById("ulnom").style.color="Red";
		ok = false;  
	}else{
		document.getElementById("ulnom").style.color="Black";
	}
	if(!test_null(document.getElementById("uprenom").value)) 
	{ 
		document.getElementById("ulprenom").style.color="Red";
		ok = false;  
	}else{
		document.getElementById("ulprenom").style.color="Black";
	}
	if(!test_null(document.getElementById("utel").value)) 
	{ 
		document.getElementById("ultel").style.color="Red";
		ok = false;  
	}else{
		document.getElementById("ultel").style.color="Black";
	}


	if(ok){
		document.getElementById("reserverform").submit();
	}
} 
</script>
<script>
	$(function() {
		$( "#date" ).datepicker( $.datepicker.regional[ "<?=$_lang?>" ] );
	});
</script>


<div class="contactBg">
  <div class="contact">
    <ul>
      <?php if($_lang==FR){ ?>
      <li><?=get_local_value($_lang,"index")?>></li>
      <li><?= $country ?>></li>
      <li><?= $restype ?>></li>
      <li><?= $resname ?>></li>
      <li><?=get_local_value($_lang,"coupon")?></li>
      <?php }else{?>
      <li><?=get_local_value($_lang,"coupon")?></li>
      <li>&lt;<?= $resname ?></li>
      <li><<?= $restype ?></li>
      <li><<?= $country ?></li>
      <li><<?=get_local_value($_lang,"index")?></li>
      <?php }?>
    </ul>
  </div>
  <!--contact end of-->
 <div class="userForm">
  <form id="reserverform" action="couponed.php" method="post">
  	   <?php if($_lang==FR){ ?>
       <h3 class="bottom20">Informations de Retrait</h3>
       <?php }?>
       <?php if($_lang==ARB){ ?>
       <h3 class="bottom20">معلومات عن الحجز</h3>
       <?php }?>
       <dl>
         <dd>
         <?php if($_lang==FR){ ?>
         <table>
         <tr>
           <td><label id="ldate"><?=get_local_value($_lang,"date")?></label><sub>*</sub><input id="date" name="date" type="text" readonly class="passeInput" value=""/>
         
           <td><label id="lhour">&nbsp;&nbsp;<?=get_local_value($_lang,"hour")?></label><sub>*</sub><input id="hour" name="hour" type="text" class="passeInput"  style="width:115px"  value=""/> 
           
           <td><label id="lminute">&nbsp;&nbsp;<?=get_local_value($_lang,"minute")?></label><sub>*</sub><input id="minute" name="minute" type="text" class="passeInput"  style="width:115px"  value=""/> 
           
           <td><label id="lpeoplenum">&nbsp;&nbsp;<?=get_local_value($_lang,"menunum")?></label><sub>*</sub><input id="peoplenum" name="peoplenum" type="text" class="passeInput"  style="width:136px"  value=""/> 
        <tr>
        </table>
        <?php }else{?>
        <table>
         <tr>
           <td><label id="ldate"><?=get_local_value($_lang,"date")?></label><sub>*</sub><input id="date" name="date" type="text" readonly class="passeInput" value=""/>
         
           <td><label id="lhour">&nbsp;&nbsp;<?=get_local_value($_lang,"hour")?></label><sub>*</sub><input id="hour" name="hour" type="text" class="passeInput"  style="width:125px"  value=""/> 
           
           <td><label id="lminute">&nbsp;&nbsp;<?=get_local_value($_lang,"minute")?></label><sub>*</sub><input id="minute" name="minute" type="text" class="passeInput"  style="width:125px"  value=""/> 
           
           <td><label id="lpeoplenum">&nbsp;&nbsp;<?=get_local_value($_lang,"menunum")?></label><sub>*</sub><input id="peoplenum" name="peoplenum" type="text" class="passeInput"  style="width:125px"  value=""/> 
        <tr>
        </table>
        <?php }?>
        </dd>
        <?php if($_lang==FR){ ?>
          <cite style="position:absolute; top:30px; left:60px; font-size:11px; color:#F00"></cite>
          <cite style="position:absolute; top:30px; left:312px; font-size:11px; width:180px"><i>Voir les horaires disponibles sur la page de l’établissement</i></cite>
          <cite style="position:absolute; top:30px; right:70px; font-size:11px; width:130px"><i>Voir les choix disponibles de menu sur les photos de l’établissement</i></cite>
        <?php }?>
        <?php if($_lang==ARB){ ?>
          <cite style="position:absolute; top:30px; left:60px; font-size:11px; color:#F00"></cite>
          <cite style="position:absolute; top:30px; left:325px; font-size:11px; width:180px"><i>تأكد من دوام المطعم في المقدمة </i></cite>
          <cite style="position:absolute; top:30px; right:60px; font-size:11px; width:130px"><i>صور العروضات في ألبوم الصور الخاص بالمطعم</i></cite>
        <?php }?>
        
       </dl>
       <dl>&nbsp;</dl>
     <?php if($_lang==FR){ ?>
     <h3>Informations Personnelles</h3>
     <?php }?>
     <?php if($_lang==ARB){ ?>
     <h3>معلومات شخصية</h3>
     <?php }?>
     <dl>
         <dd><i></i></dd> 
         <dd style="margin-bottom:50px">
          <?php if($_lang==FR){ ?>
					 <table>
        			 <tr>
        				<td><?=get_local_value($_lang,"sex")?><sub>*</sub>
		         			<select name="usex">
		                    <?php 
		                    	$sex = get_local_value($_lang,"male");
		                    	if($record["sex"]==2){
		                    		$sex = get_local_value($_lang,"female");
		                    	}
		                    ?>
		                    	<option value="<?=$record["sex"]?>"><?= $sex ?></option>
								<option value="1"><?=get_local_value($_lang,"male")?></option>
								<option value="2"><?=get_local_value($_lang,"female")?></option>
							</select>
	                  	<td><label id="ulnom">&nbsp;&nbsp;<?=get_local_value($_lang,"nom")?></label><sub>*</sub><input id="unom" name="unom" type="text" value="<?= $record["nom"] ?>" class="input90" /> 
	                 	
	                 	<td><label id="ulprenom">&nbsp;&nbsp;<?=get_local_value($_lang,"prenom")?></label><sub>*</sub><input id="uprenom" name="uprenom" type="text" value="<?= $record["prenom"] ?>" class="passeInput" style="width:110px" /> 
	                    
	                    <td><label id="ultel">&nbsp;&nbsp;<?=get_local_value($_lang,"stel")?></label><sub>*</sub><input id="utel" name="utel" type="text" value="<?= $record["tel"] ?>" class="passeInput" style="width:120px" /> 
	                    
	                    <td><label id="ulemail">&nbsp;&nbsp;<?=get_local_value($_lang,"email")?></label><sub>*</sub><input id="uemail" name="uemail" type="text" class="emailInput" style="width:206px" value="<?= $record["email"] ?>"/>
        			</tr>
        			</table>
        	<?php }else{?>
        			<table>
        			 <tr>
        				<td><?=get_local_value($_lang,"sex")?><sub>*</sub>
		         			<select name="usex">
		                    <?php 
		                    	$sex = get_local_value($_lang,"male");
		                    	if($record["sex"]==2){
		                    		$sex = get_local_value($_lang,"female");
		                    	}
		                    ?>
		                    	<option value="<?=$record["sex"]?>"><?= $sex ?></option>
								<option value="1"><?=get_local_value($_lang,"male")?></option>
								<option value="2"><?=get_local_value($_lang,"female")?></option>
							</select>
	                  	<td><label id="ulnom">&nbsp;&nbsp;<?=get_local_value($_lang,"nom")?></label><sub>*</sub><input id="unom" name="unom" type="text" value="<?= $record["nom"] ?>" class="input90" /> 
	                 	
	                 	<td><label id="ulprenom">&nbsp;&nbsp;<?=get_local_value($_lang,"prenom")?></label><sub>*</sub><input id="uprenom" name="uprenom" type="text" value="<?= $record["prenom"] ?>" class="passeInput" style="width:90px" /> 
	                    
	                    <td><label id="ultel">&nbsp;&nbsp;<?=get_local_value($_lang,"stel")?></label><sub>*</sub><input id="utel" name="utel" type="text" value="<?= $record["tel"] ?>" class="passeInput" style="width:100px" /> 
	                    
	                    <td><label id="ulemail">&nbsp;&nbsp;<?=get_local_value($_lang,"email")?></label><sub>*</sub><input id="uemail" name="uemail" type="text" class="passeInput" value="<?= $record["email"] ?>" style="width:155px" />
        			</tr>
        			</table>
        	<?php }?>
        </dd>
     </dl>
     <?php if($_lang==FR){ ?>
     <h3>Demande à l’attention du restaurant</h3>
     <?php }?>
      <?php if($_lang==ARB){ ?>
     <h3>ملاحظات</h3>
     <?php }?>
     <dl>
     	<?php if($_lang==FR){ ?>
     	<dd><i>Votre demande sera transmise au restaurant mais nous ne pouvons vous garantir qu'il pourra satisfaire toutes les demandes.</i></dd> 
        <?php }?>
        <?php if($_lang==ARB){ ?>
     	<dd><i>سنوصل ملاحظاتكم للمطعم ولاكن لا نوعدكم بتلبيت جميع طلباتكم</i></dd> 
        <?php }?>
        <dd class="bottom20">
          <textarea class="textareaBg" rows="" cols="" id="descr" name="descr"></textarea>
          <input id="restoid" name="restoid" type="hidden" value="<?= $restoid ?>"></input>
        </dd>
        <dd> 
        <code class="fl"><sub>*</sub> <?=get_local_value($_lang,"need")?></code>   
        <code class="fr" style="margin-right:50px"><input name="" type="button" value=""  onClick="suborder()" class="preferentialBtn"/></code></dd>
     </dl>
	 </form>
  </div>
  <!--contactForm end of-->
</div>
<!--contactBg end of-->
<?php
include("foot.php");
?>